/*****目标团队*****/
<template><!---->
	<search-table
	    ref="searchTable"
		:columns="[4, 7].includes(type) ? targetTeamCol4 : type == 1 ? targetTeamCol1 : targetTeamCol"
        :data="targetTeamData"
		:total=	targetTeamTotal
		:page.sync="queryTargetTeamInfo.pageIndex"
		:size.sync="queryTargetTeamInfo.pageSize"
		@change-size="getTargetSize"
		@change-page="getTargetPage"
	>
    <template slot="search">
		<Select filterable v-model="queryTargetTeamInfo.status" placeholder="请选择状态"  style="width: 150px;margin-right:15px;" 
			v-if="type !== 8" @on-change="searchTargetTeam" clearable key="common-status">
			<Option :value="1" v-if="type === 4">未攻破</Option>
			<Option :value="1" v-else-if="type === 9">未解决</Option>
			<Option :value="1" v-else>正常/防护成功</Option>
			<Option :value="2" v-if="type !== 9">被攻破</Option>
			<Option :value="3" v-if="type !== 9 && type !== 4 && !isZh">服务异常</Option>
			<Option :value="4" v-if="type !== 9 && type !== 4 && !isZh">被攻破+服务异常</Option>
			<Option :value="6" v-if="type === 9">已解决</Option>
		</Select>
		<Select filterable v-model="queryTargetTeamInfo.status" placeholder="请选择状态"  style="width: 150px;margin-right:15px;" 
			v-if="type === 8" @on-change="searchTargetTeam" clearable key="plus-status">
			<Option :value="1">未攻击未防御</Option>
			<Option :value="2">已攻击未防御</Option>
			<Option :value="3">未攻击防御异常</Option>
			<Option :value="4">已攻击防御异常</Option>
			<Option :value="5">未攻击已防御</Option>
			<Option :value="6">已攻击已防御</Option>
		</Select>
		<Select filterable v-model="queryTargetTeamInfo.targetName"
				style="width: 150px; margin-right:15px;"
				@on-change="searchTargetTeam" clearable
				:placeholder="`请选择${typeName}`">
			<Option v-for="item in targetTeamList" :value="item.name" :key="item.id" :title="item.name">{{ item.name }}</Option>
		</Select>
		<Select filterable v-model="queryTargetTeamInfo.teamName"
				style="width: 150px; margin-right:15px;"
				@on-change="searchTargetTeam" clearable
				placeholder="请选择团队">
			<Option v-for="item in accessGroupList" :value="item.name" :key="item.id" :title="item.name">{{ item.name }}</Option>
		</Select>
      <!--<DatePicker format="yyyy-MM-dd HH:mm:ss" type="daterange"  placeholder="选择日期" style="width: 200px"
                  @on-change="searchTargetPrjD"></DatePicker>-->
      <!--<Input v-model.trim="searchPrjString" search placeholder="题目显示名称" style="width: 200px" clearable @on-change="searchTargetPrj"  />-->

      <!-- <Page :total=	targetTeamTotal
            show-total show-elevator @on-page-size-change="getTargetSize"
            @on-change="getTargetPage" style="float: right">
      </Page> -->
    </template> 
    <!-- <TableList border :columns="targetTeamCol4" :data="targetTeamData" v-if="[4, 7].includes(type)"></TableList> -->
    <!-- <card-list :columns="targetTeamCol4" :data="targetTeamData" v-if="[4, 7].includes(type)"></card-list> -->
    <!-- <TableList border :columns="targetTeamCol1" :data="targetTeamData" v-else-if="type == 1"></TableList> -->
    <!-- <card-list :columns="targetTeamCol1" :data="targetTeamData" v-else-if="[1].includes(type)"></card-list> -->
    <!-- <TableList  :columns="targetTeamCol" :data="targetTeamData" v-else></TableList> -->
    <!-- <card-list :columns="targetTeamCol" :data="targetTeamData" v-else></card-list> -->
    <Modal v-model="submitFlagChallModal.show"
        :title="submitFlagChallModal.title"
        :mask-closable="false"
	    :loading="submitFlagChallModal.loading"
        @on-ok="toSubmitFlag('challformValidate')"
        @on-cancel="handleReset('challformValidate')"
        width="600px">
			<Form ref="challformValidate" :model="challformValidate" :rules="ruleChalValidate" :label-width="120">
				<!--<FormItem label="选择需要提交flag的题目" prop="chaId">
					<Select filterable v-model="challformValidate.chaId" placeholder="选择题目"  filterable>
						<Option v-for="item in challslist" :key="item.name"  :value="item.chaId+'#'+item.name">{{item.name}}</Option>
					</Select>
				</FormItem>-->
				<FormItem label="Flag" prop="flag">
					<Input type="textarea" v-model.trim="challformValidate.flag" :placeholder="`输入${typeName}Flag`"></Input>
				</FormItem>
			</Form>
	</Modal>
	<Modal v-model="reportGradeModal.show"
        :title="reportGradeModal.title"
        :mask-closable="false"
	    :loading="reportGradeModal.loading"
        @on-ok="reportGrade('gradeValidate')"
        @on-cancel="handleReset('gradeValidate')"
        width="400px">
			<Form ref="gradeValidate" :model="gradeValidate" :rules="ruleChalValidate" :label-width="80">
				<FormItem label="评分" prop="score">
					<InputNumber type="textarea" v-model="gradeValidate.score" :min="1" :max="curTarget.score" :placeholder="'输入1~'+curTarget.score+'的数字'" style="width:200px"></InputNumber>
					<!--<p style="color:#ff9900" v-if="hasApplyTag"> <Icon type="ios-information-circle-outline" />该题已经申请过提示，最高得分只能是该题目满分的一半</p>-->
				</FormItem>
			</Form>
	</Modal>
	<Modal v-model="pdfModal"
      	title="pdf预览"
      	width="60"
      	:mask-closable = "false"
      	footer-hide
      	>
      	<!--<iframe src="http://172.18.100.4:18769/ftp/edu-ftp/viewOnline/pdf/F102b386-f32c-4868-902f-00bc1886145b" width="100%" height="600px" ></iframe>-->
        <iframe :src="pdfUrl" width="100%" height="600px" scrolling="none" frameborder="0"></iframe>
	</Modal>
</search-table>
</template>

<script>
  import {getTargetTeamList_new,addTargetTeam,modifyTargetTeam,getTargetTeamInfo,delTargetTeam,queryVmWithParty,queryTargetAllot,submitFlag,reportGrade,ctfReport} from '@/api/drill_compete'
  import {queryCtfList} from '@/api/question'
  import {getaccessgrouplist} from '@/api/access_new'
	export default {
    name: 'scenes',
    props:['type','poll','drillDetail','step','scoringType'], //接受演练竞赛类型
    components:{},
	computed: {
    	typeName() {
    		return this.type === 7 ? '任务' : '题目'
		}
	},
	data(){
		const validateScore = (rule,value,callback) => {
	      	let _this = this;
	      	let score = _this.curTarget.score;
	      	if((value && (value > score || value < 1)) || value === 0){
	      		callback(new Error(`请输入1~${score}的数字`));
	      	}else{
	      		callback()
	      	}
	      }
	  	return {
        isZh : this.$route.query.path===this.$store.getters.getMenuName('multipleDrill'),// 是否是综合演练21887
        targetTeamList: [],
		  	routeParams:{
	          id:this.$route.query.id,
	          prjid:this.$route.query.prjid
	        },
	        targetModal:{
	        	show:false,
	        	title:'',
	        	loading:true,
	        	type:1 //1添加，2修改
	        },
	        submitFlagChallModal:{
	        	show:false,
	        	title:'提交Flag',
	        	loading:true
	        },
	        reportGradeModal:{
	        	show:false,
	        	title:'评分',
	        	loading:true
	        },
	        pdfModal:false,
			accessGroupList:[],
	        vmlists:[],
	        teamlists:[],
			queryTargetTeamInfo:{
				pageIndex:1,
				pageSize:10,
				sceneId:this.$route.query.id,
				sortBy:'residueScore',
				spare: 0, // 需要过滤掉备用环境
				order:'desc'
//				projectId:this.$route.query.prjid
			},
	        questionList:[],
	        formValidate: {
	          //"createTime": "2020-02-10T03:35:50.081Z",
			  //"creator": "string",
			  "description": "", //目标描述
			  "externalIp": "", //对外ip
			  "externalPort": 1, //对外端口
			  //"ip": "string",
			  "name": "", //目标名称
			  //"password": "string",
			  //"port": "string",
			  "projectId": this.$route.query.prjid,
			  "questionId": '', //题目id
			  "sceneId": this.$route.query.id,
			  "score": 0,
			  //"status": 0, //状态：1 正常/防护成功，2 被攻破，3 服务异常，4 被攻破+服务异常
			  "teamId": "",
			  "teamName": "",
			  "type": 0, //目标类型：0.单个虚拟机、1.多个虚拟机flag相同、2.多个虚拟机flag不同、3.文件类型
			  //"user": "string",
			  "visibility": 0, //可见性：是否可见- 0.不可见 1可见
			  "vmId": ""
	        },
	        ruleValidate: {
	          name: [
	            { required: true, message: '名字不能为空', trigger: 'change' }
	          ],
	          description: [
	            { required: true, message: '请输入描述信息', trigger: 'change' }
	          ],
	          type: [
	            { required: true,type:'number',message: '请选择靶标类型', trigger: 'change' },
	          ],
	          score:[
	            { required: true, type:'number',message: '请输入分值', trigger: 'change'}
	          ],
	          externalIp:[
	          	{ required: true, message: '请输入对外IP', trigger: 'change'}
	          ],
	          externalPort:[
	          	{ required: true, type:'number',message: '请输入对外端口', trigger: 'change'}
	          ],
	//        questionId:[
	//        	{ required: true, message: '请选择题目', trigger: 'change'}
	//        ],
	          visibility:[
	          	{ required: true, type:'number',message: '请选择', trigger: 'change'}
	          ],
	          vmId:[
	          	{ required: true, message: '请选择虚拟机', trigger: 'change'}
	          ],
	          teamId:[
	          	{ required: true, message: '请选择团队', trigger: 'change'}
	          ],
	        },
	        initTargetObjData:{
	          "createtime": "",
	          "createuser": localStorage.getItem('username'),
	          "frequency": 0,
	          "id": "",
	          "isshow": 1,
	          "lastupdatetime": "",
	          "modifier": "",
	          "sceneid": "",
	          "targetdes": "",
	          "targetname": "",
	          "targetsubmittype":0,
	          "targettype": 0,
	          "teamid": "",
	          "type": 0,
	          "uri": "",
	          "vmid": "",
	          "score":'0'
	        },
	        querytime:{},
	        targetTeamCol:[
	//        {
	//          type: 'index',
	//          align: 'center',
	//          ellipsis:true,
	////          width:60
	//        },
			 {
	            title:'团队名称',
	            key:'teamName',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            width:100
	          },
	          {
	            title:'题目显示名称',
	            key:'targetName',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
				width:300,
	            placement:'top-left'
	//          width:100
	          },
//	          {
//	            title:'靶标类型',
//	            key:'type',
//	            align:'center',
//	            render:(h, params) => {
//	              return h('span',this.typeFilter(params.row.type))
//	            }
//	          },
	//		  {
	//          title:'IP地址',
	//          key:'ip',
	//          align:'center',
	//          ellipsis:true,
	//          tooltip:true,
	//        },
	//        {
	//          title:'端口',
	//          key:'port',
	//          align:'center',
	//          ellipsis:true,
	//          tooltip:true,
	//        },
	//        {
	//          title:'对外IP',
	//          key:'externalIp',
	//          align:'center',
	//          ellipsis:true,
	//          tooltip:true,
	//        },
	//        {
	//          title:'对外端口',
	//          key:'externalPort',
	//          align:'center',
	//          ellipsis:true,
	//          tooltip:true,
	//        },
	          {
	            title:'分值',
	            key:'score',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            width:60
	          },
	          {
	            title:'状态',
	            key:'status',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            placement:'top-right',
				width:120,
	            render:(h,params) => {
	            	return h('Tag',{
	            		props:{
	            			color:this.statusFilter(params.row.status,'color')
	            		}
	            	},this.statusFilter(params.row.status,'text'))
	            }
	          },
	          {
	            title:'题目最后得失分时间',
	            key:'lastScoreTime',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
				width:148,
				show:() => {
					return !(this.type === 8  && this.scoringType === 1)
				}
	          },
	        ],
	        challformValidate:{//渗透演练 type == 4
//			  score:0,
				chaId:'',
				flag:''
			},
			gradeValidate:{
				"questionId": "",
			    "sceneId": this.$route.query.id,
			    "score": 0,
			    "teamId": ""
			},
			ruleChalValidate:{
			  chaId:[
			    { required: true, message: '请选择题目', trigger: 'change' },
			  ],
				flag:[
				  { required: true, message: '请输入Flag', trigger: 'change' },
				],
				score:[
				  { required: true, type:'number',message: '请输入分数', trigger: 'change' },
				  { validator: validateScore, trigger: 'change' }
				],
			},
			curTarget:{},
	        targetTeamCol4:[ //渗透演练 type == 4
			 {
	            title:'团队名称',
	            key:'teamName',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            width:100
	          },
	          {
	            title:'题目显示名称',
	            key:'targetName',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            placement:'top-left',
				  width: 240
	//          width:100
	          },
	          {
	            title:'分值',
	            key:'score',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            width:60
	          },
	          {
	            title:'攻破者',
	            key:'userName',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            width:100
	          },
	          {
	            title:'状态',
	            key:'status',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            placement:'top-right',
				width:120,
	            render:(h,params) => {
					return h('Tag',{
	            		props:{
	            			color:this.statusFilter(params.row.status,'color')
	            		}
	            	},this.statusFilter(params.row.status,'text'))
	            }
	          },
	          {
	            title:'攻破时间',
	            key:'lastScoreTime',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
				width:200
	          },
	          {
	            title:'是否需要提交Flag',
	            key:'isNeedSubmitFlag',
	            align:'center',
	            placement:'top-right',
	            render:(h,params) => {
					return h('Tag',{
						props:{
						   color:params.row.isNeedSubmitFlag == '1' ? 'var(--status-yes)' :'var(--status-no)',
						   type:"border"
						},
						on:{
		                    click:()=>{
		                      //this.showAddAndUpdate(params.row)
		                    }
		                }
					},params.row.isNeedSubmitFlag == '1' ? '是' : '否' )
				}
              },
	          /*{
	          	title:'操作',
	            align:'center',
	            width:200,
	            placement:'top-right',
	            action:true,
	            render:(h,params) => {
	            	let _this = this;
	            	console.log(_this.drillDetail);
	        		return h('div',[
	        		    h('Button',{
						  props:{
						    type:'primary',
						    size:'small',
						    disabled:!params.row.fileId
						  },
						  style:{
						    marginRight:'5px'
						  },
						  on:{
						    click:()=>{
						    }
						  }
						},[
							h('a',{
		                		attrs:{
		              				href:"/api/ftp/edu-ftp/download?id=" + params.row.fileId,
		                			download:'',
	//				                			href: `../../Learn${path}`
		                		},
		                		style:{
		                			color:params.row.fileId ? '#fff' : '#c5c8ce'
		                		}
		                	},'下载')
						]),
						h('Button',{
						  props:{
						    type:'primary',
						    size:'small',
						    disabled:!params.row.fileId
						  },
						  style:{
						    marginRight:'5px'
						  },
						  on:{
						    click:()=>{
						    	let reviewUrl = `/api/ftp/edu-ftp/viewOnline/pdf/${params.row.fileId}`;//${params.row.fileId}
						    	this.pdfUrl = `static/pdfjs/web/viewer.html?file=${encodeURIComponent(reviewUrl)}`
						    	this.pdfModal = true;
						    }
						  }
						},"预览"),
	        			h('Button',{
						  props:{
						    type:'primary',
						    size:'small',
							 disabled: (params.row.status == 2 || params.row.status == 4)
						  },
						  style:{
						    marginRight:'5px',
						    display:'none'//params.row.isNeedSubmitFlag == '1' ? 'inline-block' : 'none'
						  },
						  on:{
						    click:()=>{
						    	this.challformValidate.flag = '';
						        this.challformValidate.chaId = params.row.questionId;
						        this.curTarget = params.row;
						        this.submitFlagChallModal.show = true;
						    }
						  }
						},'提交Flag'),
						h('Button',{
						  props:{
						    type:'primary',
						    size:'small',
						    disabled:!params.row.fileId || params.row.isNeedSubmitFlag == '1' || (this.drillDetail.extension && JSON.parse(this.drillDetail.extension).stMode == 0)
						  },
						  style:{
						    marginRight:'5px',
						    width:'60px'
						  },
						  on:{
						    click:()=>{
						    	this.gradeValidate.score = 1;
						        this.gradeValidate.questionId = params.row.id;
						        this.gradeValidate.teamId = params.row.teamId;
						        this.curTarget = params.row;
						        this.reportGradeModal.show = true;
						    }
						  }
						},'评分')
	        		])
	            	}
				}*/
	        ],
	        targetTeamCol1:[ //攻防赛 type == 1 //题目显示名称、团队名称、剩余分数、每周期分数、靶标状态、最后一次扣分时间
			 {
	            title:'团队名称',
	            key:'teamName',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            width:100
	          },
	          {
	            title:'题目显示名称',
	            key:'targetName',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            placement:'top-left',
	          	width:100
	          },
	          {
	            title:'剩余分数',
	            key:'residueScore',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            width:60
	          },
	          {
	            title:'每周期分数',
	            key:'score',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            width:60,
	            render:(h,params) => {
	            	return h('span',10)
	            }
	          },
	          {
	            title:'状态',
	            key:'status',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	            placement:'top-right',
				width:120,
	            render:(h,params) => {
	            	return h('Tag',{
	            		props:{
	            			color:this.statusFilter(params.row.status,'color')
	            		}
	            	},this.statusFilter(params.row.status,'text'))
	            }
	          },
	          {
	            title:'题目最后得失分时间',
	            key:'lastScoreTime',
	            align:'center',
	            ellipsis:true,
	            tooltip:true,
	          },
	        ],
	        targetTeamData:[],
	        targetTeamTotal:0,
	        TargetId:'',
	        timeout:{},
	        pdfUrl:''
	  	}
	},
	filters:{

	},
	watch:{

	},
	beforeDestroy(){
		clearTimeout(this.timeout)
	},
	mounted(){
    	//this.getAllSence()
    	//this.getAllTargetHost();
    	//this.getAllVmlist();

    	this.getAccessGroupList();
    	//this.queryCtfQuestionList();
		if(this.step==='mid'){
			this.targetTeamCol4.push(
					{
						title:'服务状态',
						key:'serviceStatus',
						align:'center',
						ellipsis:true,
						tooltip:true,
						width:150,
						render:(h,params)=>{
							return h('span',this.handlerServiceStatus(params.row.serviceStatus))
						}
					},
			)
		}
    	this.getTargetTeamList();
		this.getTargetTeamList_new()
		if (this.type === 7) {
			this.targetTeamCol4[1].title = this.targetTeamCol4[1].title.replace('题目', '任务')
		}
	},
    methods:{
		getTargetTeamList_new(){
			getTargetTeamList_new({
				pageIndex:1,
				pageSize:2147483647,
				sceneId:this.$route.query.id,
				projectId:this.$route.query.prjid
			}).then(data => {
				if(data.code==1){
					this.targetTeamList = data.data.items || data.data;
				}else{
					this.targetTeamList = []
				}
			})
		},
    	showAddAndUpdate(info){
    		this.targetModal.show = true;
    		if(!info){
    			this.targetModal.title = '添加题目';
    			this.targetModal.type = 1;
    		}else{
    			this.targetModal.title = '修改题目';
    			this.targetModal.type = 2;
    			this.formValidate = {};
    			this.formValidate = JSON.parse(JSON.stringify(info));
    			this.question = {imageId:this.formValidate.imageId};
    			this.setTeamGroup(this.formValidate.teamId);
    			this.formValidate.externalPort = parseInt(this.formValidate.externalPort);
    		}
    	},
	  	addTargetTeam(){
	  		addTargetTeam(this.formValidate).then(data => {
	  			if(data.code==1){
	  				this.getTargetTeamList();
	  				this.$Message.info('操作成功');
	  				this.handleReset('formValidate');
	  				this.targetModal.show = false;
	  			}else{
	  				this.cancelLoading('targetModal');
	  			}
	  		}).catch(error => {
	  			this.cancelLoading('targetModal');
	  		})
	  	},
	  	modifyTargetTeam(){
	  		modifyTargetTeam(this.formValidate).then(data => {
	  			if(data.code==1){
	  				this.getTargetTeamList();
	  				this.$Message.info('操作成功');
	  				this.handleReset('formValidate');
	  				this.targetModal.show = false;
	  			}else{
	  				this.cancelLoading('targetModal');
	  			}
	  		}).catch(error => {
	  			this.cancelLoading('targetModal');
	  		})
	  	},
	  	saveTargetTeam(){
	  		this.$refs['formValidate'].validate((valid) => {
	            if (valid) {
	            	if(this.targetModal.type == 1){
	            		this.addTargetTeam();
	            	}else{
	            		this.modifyTargetTeam();
	            	}
	            }else{
	            	this.cancelLoading('targetModal');
	            }
	        })
	  	},
	  	getTargetTeamList(){
	  		clearTimeout(this.timeout);
	  		queryTargetAllot(this.queryTargetTeamInfo).then(data => {
	  			if(data.code==1){
	  				this.targetTeamData = data.data.items || data.data;
	  				this.targetTeamTotal = data.data.total;
	  				this.targetTeamData.forEach(item => {
		   				this.ctfReport(item);
		   			})
	  				if(this.poll){ //如果需要轮询
	  					this.timeout = setTimeout(() => {
		  					this.getTargetTeamList();
		  				}, 10000)
	  				}
	  			}else{

	  			}
	  		})
	  	},
	  	delTargetTeam(id){
	  		delTargetTeam(id).then(data => {
	  			if(data.code==1){
	  				this.getTargetTeamList();
	  			}else{

	  			}
	  		})
	  	},
	  	cancelLoading(name){
	    	this[name].loading = false;
	      	setTimeout(() => {
	      		this[name].loading = true;
	      	})
	    },
	    typeFilter(val){
	      let str = '';
	      switch (val) {
	      	case 0:str = 'flag';break;
	        case 1:str = '多个虚拟机flag相同';break;
	        case 2:str = '多个虚拟机flag不同';break;
	        case 3:str = '文档';break
	        default:break;
	      }
	      return str;
	    },
	    statusFilter(val,type){
	      let str = '';
	      if(type == 'text'){
	      	switch (val) {
		      	case 1:str = this.type === 9 ? '未解决' : this.type === 8 ? '未攻击未防御' : '正常';break;
				case 2:str = this.type === 8 ? '已攻击未防御' : '被攻破';break;
				case 3:str = this.type === 8 ? '未攻击防御异常' : '服务异常';break;
				case 4:str = this.type === 8 ? '已攻击防御异常' : '被攻破+服务异常';break
				case 5: return this.type === 8 ? '未攻击已防御' : '防御成功';
				case 6: return this.type === 8 ? '已攻击已防御' : '已解决';
				case 7: return'防御成功+服务异常';
		        default:break;
		    }
	      }else{
	      	switch (val) {
		      	case 1:str = 'var(--status-yes)';break;
		        case 2:str = 'var(--status-suspend)';break;
		        case 3:str = 'var(--status-suspend)';break;
		        case 4:str = 'var(--status-no)';break
				case 5: return'var(--status-no)';
				case 6: return'var(--status-yes)';
				case 7: return'var(--status-suspend)';
		        default:break;
		    }
	      }
	      return str;
	    },
	    getAllVmlist(partyId,imageId){
	        let params = {
				page:1,
				pageSize:10000,
				sortBy:'name',
				order:'asc'
			}
	        if(this.question){
	        	params.imageId = this.question.imageId;
	        }
	        if(this.group){
	        	params.party = this.group.partyId;
	        }
			queryVmWithParty(this.routeParams.prjid,params).then(data => {
				if(data.code == 1){
					this.vmlists = data.data.list || data.data;
				}
			})
	    },
	    getAccessGroupList(){
			if(!this.routeParams.id){
				return;
			}
			let params = {
				pageIndex:1,
				pageSize:2147483647,
				testId:this.routeParams.id
			};
			this.selectGroupList = [];
//			this.getPartyList();
			getaccessgrouplist(params).then(data => {
				if(data.code == 1){
					this.accessGroupList = data.data.items;
				}else if(data.code == -2) {
					this.accessGroupList = [];
				}else{
					this.$Message.warning(data.message);
				}
				//this.getUserTaskList();
			})
		},
	    getTargetSize(size){
	      this.queryTargetTeamInfo.pageSize = size;
	      this.getTargetTeamList()
	    },
	    getTargetPage(page){
	      this.queryTargetTeamInfo.pageIndex = page;
	      this.getTargetTeamList()
	    },
	    searchTargetTeam(){
	    	this.queryTargetTeamInfo.pageIndex = 1;
	        this.getTargetTeamList()
	    },
	    setTeamQuestion(val){
	    	if(!val){
	    		return
	    	}
	    	this.question = this.questionList.filter(question => question.chaId == val)[0];
	    	this.formValidate.port = this.question.port;
	    	//this.formValidate.vmId = '';
	    	this.getAllVmlist();
	    },
	    setTeamGroup(val){
	    	if(!val){
	    		return
	    	}
	    	this.group =  this.accessGroupList.filter(group => group.id == val)[0];
	    	this.formValidate.teamName = this.group.name;
	    	//this.formValidate.vmId = '';
	    	this.getAllVmlist();
	    },
	    handleReset (name) {
	      this.$refs[name].resetFields();
	//    this.addTarget = false;
	    },
	    queryCtfQuestionList(){//查询ctf题列表-不分页--不需要环境
	        let obj = {
	          pageIndex:1,
	          pageSize:2147483647,
	          isNeedEnv:'0',
	          //isNeedSubmitFlag:'1',
	          //category:this.autoPro.ctfType.join(',')
	        };
	        let _this = this;
	        queryCtfList(obj).then(data => {
	          if(data.code == 1){
	            _this.questionList = data.data.items.filter(ques => ques.imageId) || data.data;
	            if(_this.questionList.length == 0){
	            	_this.$Message.warning('该工程下没有满足要求的虚拟机');
	            }
	          }else{
	            _this.$Message.warning(data.message);
	          }
	        })
	    },
	    ctfReport(item){
	   	  let sceneId = this.$route.query.id;
	   	  let teamId = item.teamId;
	   	  ctfReport(sceneId,teamId).then(data => {
	   	  	if(data.code == 1 && data.data && data.data.length){
	   	  		this.$set(item,'fileId',data.data[0].fileId);
	   	  	}
	   	  })
	    },
	    //提交flag
		toSubmitFlag(){
			let _this = this;
			let urlId = '';
			this.$refs.challformValidate.validate((valid) => {
				if (valid) {
					let params={
						id : this.curTarget.basicTargetId,
						flag: this.challformValidate.flag
					};
					submitFlag(params).then(data=>{
						if(data.code==1){
							if(data.data.isRight == 0){
								_this.$Message.error('Flag验证失败！');
							}else{
								_this.$Message.info('Flag验证成功！');
							}
							_this.submitFlagChallModal.show = false;
							_this.queryTargetAllot();
						}else{
							_this.$Message.warning(data.message);
							_this.submitFlagChallModal.loading = false;
							setTimeout(()=>{
								_this.submitFlagChallModal.loading = true;
							},500)
						}
					}).catch(error => {
						    _this.$Message.warning(error);
							_this.submitFlagChallModal.loading = false;
							setTimeout(()=>{
								_this.submitFlagChallModal.loading = true;
							},500)
						})
				} else {
					_this.submitFlagChallModal.loading = false;
					setTimeout(()=>{
						_this.submitFlagChallModal.loading = true;
					},500)
					//this.$Message.error('表单输入有误')
				}
			}).catch(error => {
				_this.submitFlagChallModal.loading = false;
				setTimeout(()=>{
					_this.submitFlagChallModal.loading = true;
				},500)
			})
		},
		reportGrade(){
			this.$refs.gradeValidate.validate((valid) => {
				if(valid){
					reportGrade(this.gradeValidate).then(data => {
						if(data.code == 1){
							this.reportGradeModal.show = false;
							this.$Message.info('操作成功');
							this.queryTargetAllot();
						}else{
							this.reportGradeModal.loading = false;
							setTimeout(()=>{
								this.reportGradeModal.loading = true;
							},500)
							this.$Message.warning(data.message);
						}
					}).catch(error => {
						this.reportGradeModal.loading = false;
						setTimeout(()=>{
							this.reportGradeModal.loading = true;
						},500)
						this.$Message.error(error.response.data.message);
					})
				}else{
					this.reportGradeModal.loading = false;
					setTimeout(()=>{
						this.reportGradeModal.loading = true;
					},500)
				}
			}).catch(() => {
				this.reportGradeModal.loading = false;
				setTimeout(()=>{
					this.reportGradeModal.loading = true;
				},500)
			})
		},
		handlerServiceStatus(value){
    		const mapStatus = {
				1:'正常',
				2:'异常'
			};
    		return mapStatus[value];
		}

  }
}
</script>

<style>
  .drillsTable .ivu-poptip-body {
    text-align: left!important;
  }
  .scenesHeader{
    margin-bottom: 16px;
  }
  .drillTables{
    min-height: 300px;
  }
  .drillsTable.ivu-table-wrapper{
    overflow: inherit;
  }
</style>
<style scoped>
  .targetHeader{
    /*padding: 10px;*/
    margin:15px 0;
  }
</style>
